package com.NateOnBiz.crypto;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import nateon.ncrypto.util.Base64;

public class Const {
	public static final String client_msg_txt = "datas/client.msg.txt";
	public static final String server_msg_txt = "datas/server.msg.txt";
	public static final String key_from_server = "out/key.from.server";
	public static final String enc_session_key_from_client = "out/enc.session.key.from.client";
	public static final String enc_message_from_client = "out/enc.message.from.client";
	public static final String enc_message_from_server = "out/enc.message.from.server";
	public static final String plain_message_from_client = "out/plain.message.from.client";
	public static final String plain_message_from_server = "out/plain.message.from.server";

	public static void writeFile(String name, byte[] body) throws IOException {
		FileOutputStream fs = new FileOutputStream(name);
		fs.write(body);
		fs.close();
	}

	public static byte[] readFile(String name) throws IOException {
		FileInputStream is = new FileInputStream(name);
		byte[] buf = new byte[is.available()];
		is.read(buf);
		is.close();
		return buf;
	}

	public static byte[] fromBase64(byte[] raw) {
		return Base64.decode(new String(raw));
	}

	public static String toBase64(byte[] raw) {
		return Base64.encode(raw);
	}
}
